package synchronized锁重入;
class Main
{
	public int i=10;
	synchronized public void operateIMainMethod()
	{
		try {
			i--;
			System.out.println("main print i="+i);
			Thread.sleep(1000);
		}
		catch(InterruptedException e)
		{
			e.printStackTrace();
		}
	}
}
class Sub extends Main{
	synchronized public void operateISubMethod()
	{
		try {
			while(i>0)
			{
				i--;
				System.out.println("sub print i="+i);
				Thread.sleep(100);
				this.operateIMainMethod();
			}
		}
		catch(InterruptedException e)
		{
			e.printStackTrace();
		}
	}
}
public class Test2_14 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Thread thread=new Thread() {
			public void run()
			{
				Sub sub=new Sub();
				sub.operateISubMethod();
			}
		};
		
		thread.start();
	}

}
